home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / fix_fat.zip / FAT.TXT < prev    next >
Text File  |  1985-06-15  |  8KB  |  147 lines

  1.     This library contains three small utilities for recovering from 
  2. several possible floppy disk problems.  As far as I know, they will 
  3. probably only work on dual-sided, dual-density MS-DOS disks.  All IO is 
  4. done with MS-DOS function calls, so the routines are probably pretty 
  5. portable.  My only experience with MS-DOS is with version 2.1, so
  6. I'm afraid these routines may not work with earlier (or later) versions 
  7. of the operating system.  However, I have included the DeSmet C sources 
  8. for the routines, so you may be able to generalize the routines after 
  9. reading the tutorial below.
  10.  
  11.     I have found these routines useful for recovering from two types of 
  12. "lost data" problems on my diskettes.  The first type of situation is 
  13. when a file is mistakenly deleted from the disk.  A more complicated 
  14. situation arises when the directory or file allocation tables somehow 
  15. become corrupted (in my case this happened when I mistakenly switched 
  16. diskettes while files were still open).
  17.  
  18.     If you should encounter one of the above problems yourself, DON'T 
  19. PANIC!!!!  Immediately STOP WHATEVER YOU ARE DOING and think carefully 
  20. about the best way to recover.  It is important not to write anything 
  21. else on the diskette as it may overwrite data you are trying to save.  
  22. Make a backup copy of the damaged diskette with the DISKCOPY command 
  23. before doing anything else, as these procedures are very powerful, and 
  24. can easily compound your problems if you make a mistake.
  25.  
  26.     This document is divided into two parts.  The first section is a 
  27. tutorial which is based on Appendix C of the PC-DOS reference manual.  
  28. It assumes less technical expertise on your part than Appendix C does 
  29. however.  It is followed by detailed descriptions of of the three
  30. utilities included in this package: FAT, PFAT, and TOSECT.
  31.  
  32.  
  33.                             Tutorial
  34.                             --------
  35.  
  36.     In this section, I will give you enough background in how DOS stores 
  37. your information on diskettes to enable to use the utilities in this 
  38. package to recover them.  I'll assume that you have some knowledge of 
  39. the MS-DOS operating system, but that you are not necessarily a computer 
  40. expert.  The first part of this tutorial deals with the general 
  41. organization of DOS files on disk.  It is followed by sections on the 
  42. disk directories and file allocation tables.  Two important topics in 
  43. restoring the data are treated in appendices: the DEBUG program, and 
  44. hexadecimal notation.  If you are unfamiliar with either of these 
  45. topics, I would advise reading the appendices before proceeding with the 
  46. rest of this section.
  47.  
  48. NOTE:  In the following sections, I will often use Hexadecimal notation 
  49. for numbers.  A hexadecimal number will be followed by a captital X.  
  50. More details about hexadecimal notation can be found in appendix B.  
  51. Some examples of hexadecimal numbers are given below:
  52.  
  53.     Hexadecimal Number        Decimal Number
  54.     ------------------      --------------
  55.             5X                      5
  56.            10X                     16
  57.            33X                     51
  58.           200X                    512
  59.  
  60. DISK ORGANIZATION
  61.  
  62.     This section describes the organization of double sided double
  63. density MS-DOS disks.  If your diskettes were formatted with DOS 2.0, 
  64. they will be formatted as described below.  Trying to use these 
  65. utilities with other versions of DOS or other diskette formats will 
  66. produce unpredictable results.
  67.  
  68.     The floppy disks used by DOS to store data are organized into units
  69. called sectors.  Each sector on a DOS diskette can hold 512 bytes
  70. of information (a byte is the amount of computer storage necessary
  71. to hold one character of data).  The sectors are organized into
  72. larger units called clusters and tracks.  A cluster is two
  73. consecutive sectors on the disk.  A track consists of a group of 9
  74. sectors, but you won't have to worry about them since we will only
  75. be dealing with sectors and clusters.
  76.  
  77.     The first few sectors on each diskettes have special purposes
  78. assigned to them.  We will refer to the sectors by their logical sector 
  79. numbers (this is the same scheme used by the DOS DEBUG program).  The 
  80. first logical sector (number 0X) is the boot record.  The next four 
  81. sectors (logical sectors 1X-4X) are for two copies of the disk's File
  82. Allocation Table (FAT).  These tell the operating system where the
  83. consecutive pieces of a file arer located on the disk.  The FAT will be
  84. explained in gory detail in a later section.  The FAT's are followed by
  85. the Root Directory for the diskette (sectors 5X - BX ).  This contains information about
  86. all of the files stored in the diskette's root directory.  It also
  87. contains information about the diskettes subdirectories, which are
  88. treated by the operating system as just a special kind of file.
  89.  
  90.     The logical sectors from CX to the end of the diskette are the 
  91. diskette's data area.  They contain the actual information you have
  92. stored in files.  There are several types of files which you might have 
  93. in your data area.  Some of them are easier to recover than others.  The 
  94. easiest type of files to piece back together are ASCII files.  These are 
  95. basically normal text files that can be typed on the terminal.  When 
  96. sectors from these files are examined with the DEBUG utility, you can 
  97. see the text that is stored in these files by useing the d command.  The 
  98. text will appear as strings of characters on the left hand side of the 
  99. display.  These are the easiest kinds of files to recover.
  100.  
  101.     Another type of file is the kind I call "almost ASCII files".  These 
  102. files are produced by word processing programs, data base programs, and 
  103. many interpreters (such as BASIC).  They consist of mostly ASCII 
  104. characters that can also be displayed with the DEBUG d command.  The 
  105. things that makes them a little more complicated to recover than pure 
  106. ASCII files is that they also contain other information besides these 
  107. text characters (such as word processing codes for bold face, italics, 
  108. and underlining).  While these files are harder to restore than the pure 
  109. ASCII files, they usually contain enough ASCII characters to be able to 
  110. piece them back together if you are familiar with the file's contents.
  111.  
  112.     The hardest kinds of files to recover are binary files.  These 
  113. are files such as programs ( COM and EXE files ) and unformatted data 
  114. files produced by some programming languages, data base programs, and 
  115. spreadsheet programs.  I wouldn't suggest even attempting to restore 
  116. these files unless you are an extremely competent assembly language 
  117. programmer and very familiar with the files contents.  There is one 
  118. exception to the above situation however which will be discussed in more 
  119. detail in the FAT section.  This occurs when the file is suspected to 
  120. occupy consecutive clusters on the disk.
  121.  
  122.     Another class of files in the data area are subdirectories.  They 
  123. are stored in the same way as ordinary files except for a special 
  124. notation that is made in their parent directory.  The format of these 
  125. files is the same as that of the root directory.  I will explain more 
  126. about them in the directory section below.
  127.  
  128.     In summary, the smallest unit on the diskette with which we will 
  129. work is called a byte (the amount of storage needed for one character).  
  130. The next largest unit is a sector which consists of 512 (200X) bytes.  
  131. The sectors are numbered starting with 0.  Two consecutive sectors make 
  132. up a cluster which has 400X bytes.  The first twelve sectors on the 
  133. diskette (sectors 0X to BX) contain special information that tell the 
  134. operating system where the file information is physically located on the 
  135. disk.  The rest of the sectors contain the actual file data.
  136.  
  137.  
  138. DIRECTORIES
  139.  
  140.     The directories tell the operating system essential information
  141. about each file on the disk.  The easiest directory to find is the root 
  142. directory stored in blocks 5X to BX.  The directory consists of 112
  143. 32-byte entries.  If you only want to undelete a file you need to know 
  144. about the first byte in the file name part of the entry and how to find 
  145. where the beginning of the file is on the disk.  If the entire directory 
  146. was destroyed, you'll need to